<?php

/*
 * 单条路由
 */
Route::set(
        array(
            'uri' => '/web/route/login/reg/user/(<uid>)/password/(<password>)',
            'bind' => array('uid' => '\d+', 'password' => '.*'),
            'module' => 'Web',
            'controller' => 'Route\\Login',
            'action' => 'reg',
            'name' => 'route/login/reg',
        )
);

/*
 * 多条路由
 */
Route::set(
        array(
            array(
                'uri' => '/web/route/login/login/user/(<uid>)/password/(<password>)',
                'bind' => array('uid' => '\d+', 'password' => '.*'),
                'module' => 'Web',
                'controller' => 'Route\\Login',
                'action' => 'login',
                'name' => 'route/login/login',
            ),
            array(
                'uri' => '/web/route/login/recover',
                'module' => 'Web',
                'controller' => 'Route\\Login',
                'action' => 'recover',
                'name' => 'route/login/recover',
            )
        )
);

/*
 * 分组路由和路由缓存
 */
if (!$route_web = Route::cache('web')) {
    
    $route_web = Route::group(array('uri' => '/web/route', 'controller' => 'Route', 'module' => 'Web', 'name' => 'route'), array(
                array(
                    'uri' => '/login/logout',
                    'controller' => 'Login',
                    'action' => 'logout',
                    'name' => 'login/logout',
                ),
                Route::group(array('uri' => '/login', 'controller' => 'Login', 'name' => 'login'), array(
                    array(
                        'uri' => '/reset/(<uid>)/password/(<password>)',
                        'bind' => array('uid' => '\d+', 'password' => '.*'),
                        'action' => 'reset',
                        'name' => 'reset',
                    ),
                ))
    ));

    Route::cache('web', $route_web);
}


Route::set($route_web);

// dump(Route::get());

/*
* 生成的路由表
* 
* Array
* (
*     [route/login/reg] => Array
*         (
*             [uri] => /web/route/login/reg/user/()/password/()
*             [bind] => Array
*                 (
*                     [uid] => \d+
*                     [password] => .*
*                 )
* 
*             [module] => Web
*             [controller] => Route\Login
*             [action] => reg
*             [name] => route/login/reg
*         )
* 
*     [route/login/login] => Array
*         (
*             [uri] => /web/route/login/login/user/()/password/()
*             [bind] => Array
*                 (
*                     [uid] => \d+
*                     [password] => .*
*                 )
* 
*             [module] => Web
*             [controller] => Route\Login
*             [action] => login
*             [name] => route/login/login
*         )
* 
*     [route/login/recover] => Array
*         (
*             [uri] => /web/route/login/recover
*             [module] => Web
*             [controller] => Route\Login
*             [action] => recover
*             [name] => route/login/recover
*         )
* 
*     [route/login/logout] => Array
*         (
*             [uri] => /web/route/login/logout
*             [controller] => Route\Login
*             [action] => logout
*             [name] => route/login/logout
*             [module] => Web
*         )
* 
*     [route/login/reset] => Array
*         (
*             [uri] => /web/route/login/reset/()/password/()
*             [bind] => Array
*                 (
*                     [uid] => \d+
*                     [password] => .*
*                 )
* 
*             [action] => reset
*             [name] => route/login/reset
*             [controller] => Route\Login
*             [module] => Web
*         )
* 
* )
*/